// store.js
import { defineStore } from 'pinia';
import { WmsApi } from '../api/wh';

export const useMyStore = defineStore('myStore', {
	state: () => ({
		safeStorage: null, // 假设这是你想要存储的数据
		error: null, // 用于存储可能出现的错误
		beClicked: true,
    timeControl:null,
    outTimeControl:null
	}),

	actions: {
		async registerSafeStorage() {
			try {
				await WmsApi()
					.SafeStorage(1, 10)
					.then((res) => {
						this.safeStorage = res.data.result.total;
					});
			} catch (error) {
				// 让表单组件显示错误
				return error;
			}
		},
    async registerTimeControl() {
			try {
				await WmsApi()
					.TimeControl(1, 10)
					.then((res) => {
						this.timeControl = res.data.result.total;
					});
			} catch (error) {
				// 让表单组件显示错误
				return error;
			}
		},
    async registerOutTimeControl() {
			try {
				await WmsApi()
					.outTimeControl(1, 10)
					.then((res) => {
						this.outTimeControl = res.data.result.total;
					});
			} catch (error) {
				// 让表单组件显示错误
				return error;
			}
		},

	},
});
